#include "iic.h"
#include "sys.h"
#define PCF8591W 0x90
#define PCF8501R 0x91



u8 readPcf8591(u8 chn)
{
	u8 val = 0;
	EA = 0;
	IIC_Start();
	IIC_SendByte(PCF8591W);
	if(!IIC_WaitAck())
	{
		
	}
	IIC_SendByte(chn);
	if(!IIC_WaitAck())
	{
		
	}
	IIC_Stop();
	somenop;
	IIC_Start();
	IIC_SendByte(PCF8501R);
	if(!IIC_WaitAck())
	{
		
	}
	val = IIC_RecByte();
	IIC_Ack(0);
	IIC_Stop();
	EA = 1;
	return val;
}